﻿<!--
// ****************************************************************************
// <author>mishkin Ivan</author>
// <email>Mishkin_Ivan@mail.ru</email>
// <date>28.01.2015</date>
// <project>ItemsFilter</project>
// <license> GNU General Public License version 3 (GPLv3) </license>
// ****************************************************************************
-->
<UserControl x:Class="Northwind.NET.Sample.View.EmployeesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Sample="clr-namespace:Northwind.NET.Sample"
             xmlns:bsFilter="http://schemas.bolapansoft.com/xaml/Controls/ItemsFilter"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:vw="clr-namespace:Northwind.NET.Sample.View"
             d:DesignHeight="600"
             d:DesignWidth="713"
             mc:Ignorable="d">
    <UserControl.Resources>
        <vw:TextToImageSourceConverter x:Key="TextToImageSourceConverter" />
        <CollectionViewSource x:Key="EmployeesViewSource" Source="{Binding Path=Employees, Source={StaticResource Workspace}}" />
    </UserControl.Resources>
    <Grid DataContext="{StaticResource EmployeesViewSource}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="215" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <bsFilter:FilterDataGrid x:Name="employesDataGrid"
                                 Grid.ColumnSpan="2"
                                 AutoGenerateColumns="False"
                                 EnableRowVirtualization="True"
                                 IsSynchronizedWithCurrentItem="True"
                                 ItemsSource="{Binding}"
                                 RowDetailsVisibilityMode="VisibleWhenSelected">
            <DataGrid.Columns>
                <DataGridTemplateColumn x:Name="iDColumn"
                                        Width="SizeToHeader"
                                        Header="ID">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding ID}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn x:Name="firstNameColumn"
                                    Width="Auto"
                                    Binding="{Binding FirstName}"
                                    Header="First Name" />
                <DataGridTextColumn x:Name="lastNameColumn"
                                    Width="Auto"
                                    Binding="{Binding LastName}"
                                    Header="Last Name" />
                <DataGridTemplateColumn Width="Auto" Header="HireDate">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <DatePicker SelectedDate="{Binding HireDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn x:Name="countryColumn"
                                    Width="Auto"
                                    Binding="{Binding Country}"
                                    Header="Country" />
                <DataGridTextColumn x:Name="cityColumn"
                                    Width="Auto"
                                    Binding="{Binding City}"
                                    Header="City" />
                <DataGridTemplateColumn x:Name="birthDateColumn"
                                        Width="Auto"
                                        Header="Birth Date"
                                        bsFilter:ColumnFilter.BindingPath="BirthDate">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <DatePicker SelectedDate="{Binding BirthDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </bsFilter:FilterDataGrid>
        <Grid x:Name="grid1"
              Grid.Row="1"
              Margin="5,10"
              Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
              DataContext="{Binding Path=/,
                                    Source={StaticResource EmployeesViewSource}}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Label Grid.Row="0"
                   Grid.Column="0"
                   Margin="3,5,3,3"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Title:" />
            <TextBox x:Name="titleTextBox"
                     Grid.Row="0"
                     Grid.Column="1"
                     Width="120"
                     Height="23"
                     Margin="3,5,3,3"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Center"
                     Text="{Binding Title,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}" />
            <Label Grid.Row="1"
                   Grid.Column="0"
                   Margin="3"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Title Of Courtesy:" />
            <TextBox x:Name="titleOfCourtesyTextBox"
                     Grid.Row="1"
                     Grid.Column="1"
                     Width="120"
                     Height="23"
                     Margin="3"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Center"
                     Text="{Binding TitleOfCourtesy,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}" />
            <Label Grid.Row="2"
                   Grid.Column="0"
                   Margin="3"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="First Name:" />
            <TextBox x:Name="firstNameTextBox"
                     Grid.Row="2"
                     Grid.Column="1"
                     Width="120"
                     Height="23"
                     Margin="3"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Center"
                     Text="{Binding FirstName,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}" />
            <Label Grid.Row="3"
                   Grid.Column="0"
                   Margin="3"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Last Name:" />
            <TextBox x:Name="lastNameTextBox"
                     Grid.Row="3"
                     Grid.Column="1"
                     Width="120"
                     Height="23"
                     Margin="3"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Center"
                     Text="{Binding LastName,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}" />
            <Label Grid.Row="4"
                   Grid.Column="0"
                   Margin="3"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Birth Date:" />
            <DatePicker x:Name="birthDateDatePicker"
                        Grid.Row="4"
                        Grid.Column="1"
                        Margin="3"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Center"
                        SelectedDate="{Binding BirthDate,
                                               Mode=TwoWay,
                                               NotifyOnValidationError=true,
                                               ValidatesOnExceptions=true}" />
            <Label Grid.Row="5"
                   Grid.Column="0"
                   Margin="3"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Extension:" />
            <TextBox x:Name="extensionTextBox"
                     Grid.Row="5"
                     Grid.Column="1"
                     Width="120"
                     Height="23"
                     Margin="3"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Center"
                     Text="{Binding Extension,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}" />
            <Label Grid.Row="6"
                   Grid.Column="0"
                   Margin="3"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Hire Date:" />
            <DatePicker Grid.Row="6"
                        Grid.Column="1"
                        Margin="3"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Center"
                        SelectedDate="{Binding HireDate,
                                               Mode=TwoWay,
                                               NotifyOnValidationError=true,
                                               ValidatesOnExceptions=true}" />
            <Label Grid.Row="7"
                   Grid.Column="0"
                   Margin="3"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Reports To:" />
            <TextBox x:Name="reportsToTextBox"
                     Grid.Row="7"
                     Grid.Column="1"
                     Width="120"
                     Height="23"
                     Margin="3"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Center"
                     Text="{Binding ReportsTo,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}" />

        </Grid>
        <Grid Grid.Row="1"
              Grid.Column="1"
              Margin="5,10"
              Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
              DataContext="{Binding Path=/,
                                    Source={StaticResource EmployeesViewSource}}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Label Grid.Row="0"
                   Grid.Column="0"
                   Margin="3,6,0,3"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Photo:" />
            <TextBox x:Name="photoTextBox"
                     Grid.Row="0"
                     Grid.Column="1"
                     Width="120"
                     Height="23"
                     Margin="3,7,0,5"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Center"
                     Text="{Binding Photo,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}" />
            <Label Grid.Row="1"
                   Grid.Column="0"
                   Margin="3,3,0,4"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Region:" />
            <TextBox x:Name="regionTextBox"
                     Grid.Row="1"
                     Grid.Column="1"
                     Width="120"
                     Height="23"
                     Margin="3,5,0,5"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Center"
                     Text="{Binding Region,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}" />
            <Label Grid.Row="2"
                   Grid.Column="0"
                   Margin="3,4,0,3"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Country:" />
            <TextBox x:Name="countryTextBox"
                     Grid.Row="2"
                     Grid.Column="1"
                     Width="120"
                     Height="23"
                     Margin="3,5,0,5"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Center"
                     Text="{Binding Country,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}" />
            <Label Grid.Row="3"
                   Grid.Column="0"
                   Margin="3,3,0,4"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="City:" />
            <TextBox x:Name="cityTextBox"
                     Grid.Row="3"
                     Grid.Column="1"
                     Width="120"
                     Height="23"
                     Margin="3,5,0,5"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Center"
                     Text="{Binding City,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}" />
            <Label Grid.Row="4"
                   Grid.Column="0"
                   Margin="3,4,0,3"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Postal Code:" />
            <TextBox x:Name="postalCodeTextBox"
                     Grid.Row="4"
                     Grid.Column="1"
                     Width="120"
                     Height="23"
                     Margin="3,5,0,5"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Center"
                     Text="{Binding PostalCode,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}" />
            <Label Grid.Row="5"
                   Grid.Column="0"
                   Margin="3,3,0,4"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Address:" />
            <TextBox x:Name="addressTextBox"
                     Grid.Row="5"
                     Grid.Column="1"
                     Grid.ColumnSpan="2"
                     Height="Auto"
                     MinHeight="23"
                     Margin="3,5"
                     VerticalAlignment="Center"
                     Text="{Binding Address,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}"
                     TextWrapping="Wrap" />
            <Label Grid.Row="6"
                   Grid.Column="0"
                   Margin="3,4,0,3"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Content="Notes:" />
            <TextBox x:Name="notesTextBox"
                     Grid.Row="6"
                     Grid.Column="1"
                     Grid.ColumnSpan="2"
                     Height="Auto"
                     MinHeight="23"
                     Margin="3,5"
                     VerticalAlignment="Center"
                     Text="{Binding Notes,
                                    Mode=TwoWay,
                                    NotifyOnValidationError=true,
                                    ValidatesOnExceptions=true}"
                     TextWrapping="Wrap" />
            <Image Grid.Row="0"
                   Grid.RowSpan="5"
                   Grid.Column="2"
                   Width="100"
                   Height="100"
                   Margin="8"
                   VerticalAlignment="Top"
                   Source="{Binding Photo,
                                    Converter={StaticResource TextToImageSourceConverter}}" />
        </Grid>

    </Grid>
</UserControl>
